package ws

import (
	"gitee.com/crack007/goose/gsjob"
)

type SessionJob struct {
	idleTimeout IIdleTimeout
	*gsjob.Job
}

func (x *SessionJob) Run() {
	if x.idleTimeout != nil && x.idleTimeout.IsTimeout() {
		x.idleTimeout.OnTimeout()
	}
}

func NewSessionJob(idleTimeout IIdleTimeout, jobName string, scheduleConfig *gsjob.ScheduleConfig) *SessionJob {
	sessionJob := &SessionJob{
		idleTimeout: idleTimeout,
	}
	sessionJob.Job = gsjob.NewJob(jobName, scheduleConfig, sessionJob)
	return sessionJob
}
